package webbandidong.model;

import java.io.Serializable;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class OrderDetailsId implements Serializable {

    @ManyToOne
    private Mobile mobile;

    @ManyToOne
    private Order mobileOrder;

    public OrderDetailsId() {
        
    }

    public OrderDetailsId(Mobile mobile, Order mobileOrder) {
        this.mobile = mobile;
        this.mobileOrder = mobileOrder;
    }

    public Mobile getMobile() {
        return mobile;
    }

    public void setMobile(Mobile mobile) {
        this.mobile = mobile;
    }

    public Order getMobileOrder() {
        return mobileOrder;
    }

    public void setMobileOrder(Order mobileOrder) {
        this.mobileOrder = mobileOrder;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || obj.getClass() != OrderDetailsId.class) {
            return false;
        }
        else {
            OrderDetailsId orderDetailsId = (OrderDetailsId)obj;
            if ((mobile == null && orderDetailsId.getMobile() != null) ||
                    (mobile != null && orderDetailsId.getMobile() == null) ||
                    (mobile != null && orderDetailsId.getMobile() != null &&
                    !mobile.equals(orderDetailsId.getMobile()))) {
                return false;
            }
            if ((mobileOrder == null && orderDetailsId.getMobileOrder() != null) ||
                    (mobileOrder != null && orderDetailsId.getMobileOrder() == null) ||
                    (mobileOrder != null && orderDetailsId.getMobileOrder() != null &&
                    !mobileOrder.equals(orderDetailsId.getMobileOrder()))) {
                return false;
            }
            return true;
        }
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 11 * hash + (this.mobile != null ? this.mobile.hashCode() : 0);
        hash = 11 * hash + (this.mobileOrder != null ? this.mobileOrder.hashCode() : 0);
        return hash;
    }
}
